package org.wyp.wang;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.config.IniSecurityManagerFactory;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.util.Factory;

/**
 * Created by lenovo on 2017/6/26.
 */
public class WangUtils {
    public static void login(String fileLocation,String pricipal,String credential){
        Factory<SecurityManager> factory = new IniSecurityManagerFactory(fileLocation);
        SecurityManager securityManager = factory.getInstance();
        SecurityUtils.setSecurityManager(securityManager);
        SecurityUtils.getSubject().login(new UsernamePasswordToken(pricipal,credential));
    }
}
